//C13:ep13_2_2.c: copy file.
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    FILE *f_read, *f_write;
    char ch;
    if(argc != 3)
    {
        fprintf(stderr, "Please inter a filename\n");
        exit(0);
    }

    if((f_read = fopen(argv[1], "r")) == NULL)
    {
        fprintf(stderr, "cannot open readfile\n");
    }

    if((f_write = fopen(argv[2], "w")) == NULL)
    {
        fprintf(stderr, "cannot open writefile\n");
        exit(0);
    }

    while(!feof(f_read))
    {
        fputc(fgetc(f_read), f_write);
    }

    fclose(f_read);
    fclose(f_write);
    exit(0);
}
